<template>
  <div>
    <el-dialog
      class="imgCode"
      title="图片二维码"
      :visible="showCode"
      :before-close="handleClose"
    >
      <canvas ref="canvas" class="mycanvas"></canvas>
    </el-dialog>
  </div>
</template>

<script>
import QrCode from 'qrcode'
export default {
  props: ['showCode'],
  methods: {
    showCanvas (img) {
      this.$nextTick(() => {
        QrCode.toCanvas(this.$refs.canvas, img, {
          width: 250,
          height: 250
        })
      })
    },
    handleClose () {
      this.$emit('update:showCode', false)
    }
  }
}
</script>

<style lang="scss">
.imgCode {
  text-align: center;
}
</style>
